﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AsLib;
using AsPlugInManager;

namespace NNLInterface
{
    public partial class frmDeptWorkDays : NNLInterface.frmBaseBasicEntry
    {
       public frmDeptWorkDays()
        {
            InitializeComponent();
            this.layOUT = this.layOut;
        }


        public frmDeptWorkDays(IASPArgList argList)
        {
            InitializeComponent();
            common.agrs = (ASPArgList)argList;
            this.layOUT = this.layOut;
            this.barInformation.Visible = false;
           
        }

        private void frmDeptWorkDays_Load(object sender, EventArgs e)
        {
            this.iniFormData("vie_DeptWorkDays", "itemid");
        }



        #region 重写基窗体方法

        //当listgrid行移动时，将表格中的数据设定到显示控件中
        protected override void subSetData(DataRow dr)
        {

            common.SetGridData(dr, layOut);
          
        }

        //设定验证条件
        protected override void subSetValidCondition()
        {
            base.subSetValidCondition();
            //设定部门编号不能为空
            DataValid.SetControlValidBlank(this.validData, this.lokDept, "部门不能为空！");

        }

        //设定只读
        protected override void subSetContolRead()
        {
            base.subSetContolRead();
            this.lokDept.Properties.ReadOnly = true;
            //this.txtApsItemNo.Properties.ReadOnly = true;
            //this.txtErpItemNo.Properties.ReadOnly = true;
        }


        //格式化表格各项目格式
        protected override void subSetGridFormat()
        {
            //common.SetGridColumnPercentFormat(this.ListView, new int[] { 3, 4, 5 });
        }

        //更新数据源并设定焦点
        protected override void subSetDataSource()
        {
            common.SetDataSource(this.Name, this.layOut);
            this.lokDept.Focus();
        }


        


        #endregion

        #region 数据更新

        private void  frmDeptWorkDays_EditButtononClick(common.DataModifyMode dataMode)
        {
            switch (dataMode)
            {
                case common.DataModifyMode.add:
                    this.strInsertSql = "INSERT INTO DeptWorkDays \n"
                                       + "( \n"
                                       + "	DeptNo, \n"
                                       + "	N1, \n"
                                       + "	N2, \n"
                                       + "	N3, \n"
                                       + "	N4, \n"
                                       + "	N5, \n"
                                       + "	N6, \n"
                                       + "	Remark, \n"
                                       + "	UptDate \n"
                                       + ")"
                                       + "values ('"
                                       + this.lokDept.Text + "',"
                                       + this.numN1.Value.ToString() + ","
                                       + this.numN2.Value.ToString() + ","
                                       + this.numN3.Value.ToString() + ","
                                       + this.numN4.Value.ToString() + ","
                                       + this.numN5.Value.ToString() + ","
                                       + this.numN6.Value.ToString() + ",'"
                                       + this.txtRemark.Text + "',"
                                       + "getdate())";
                    break;
                case common.DataModifyMode.edit:
                    this.strUpdateSql = " UPDATE DeptWorkDays  \n"
                                   + "   SET   "
                                   + "   N1=" + this.numN1.Value.ToString() + ","
                                   + "   N2=" + this.numN2.Value.ToString() + ","
                                   + "   N3=" + this.numN3.Value.ToString() + ","
                                   + "   N4=" + this.numN4.Value.ToString() + ","
                                   + "   N5=" + this.numN5.Value.ToString() + ","
                                   + "   N6=" + this.numN6.Value.ToString() + ","
                                   + "   remark ='" + this.txtRemark.Text + "',"
                                   + "   UptDate =getdate() "
                                   + "   WHERE ITEMID=" + txtItemID.Text;
                    break;
                default:
                    this.strDeleteSql = string.Format("delete from DeptWorkDays  WHERE itemid='{0}'", this.txtItemID.Text);
                                     
                    break;
            }
        }
        #endregion
    }
}
